﻿using Husb.DataUtil;
using System;
using System.Data;
namespace CentralOffice.Enterprise.Data {


    partial class EnterpriseDataSet
    {
        public partial class EnterprisesRow
        {
            #region GenerateFilterExpression
            
            public static string GenerateFilterExpression(
                string name, 
                string queryNumber,
                string enterpriseNumber,
                string contact,
                string telephone1,
                string telephone2,
                string webSite,
                string email,
                string postcode,
                string address,
                Guid   categoryId,
                decimal scale,
                int     employeeCount
                )
            {
                string where = "";
                //where += DataAccessUtil.GetPartWhereCondition("Id", this.Id);
                where += DataAccessUtil.GetPartWhereCondition("Name", name);
                where += DataAccessUtil.GetPartWhereCondition("QueryNumber", queryNumber);
                where += DataAccessUtil.GetPartWhereCondition("EnterpriseNumber", enterpriseNumber);
                where += DataAccessUtil.GetPartWhereCondition("Contact", contact);
                where += DataAccessUtil.GetPartWhereCondition("Telephone1", telephone1, true);
                where += DataAccessUtil.GetPartWhereCondition("Telephone2", telephone2, true);
                where += DataAccessUtil.GetPartWhereCondition("WebSite", webSite);
                where += DataAccessUtil.GetPartWhereCondition("Email", email);
                where += DataAccessUtil.GetPartWhereCondition("Postcode", postcode, true);
                where += DataAccessUtil.GetPartWhereCondition("Address", address);

                where += DataAccessUtil.GetPartWhereCondition("CategoryId", categoryId);
                where += DataAccessUtil.GetPartWhereCondition("Scale", scale);
                where += DataAccessUtil.GetPartWhereCondition("EmployeeCount", employeeCount);

                return where;
            }

            public string GenerateFilterExpression()
            {
                string where = "";
                where += DataAccessUtil.GetPartWhereCondition("Id", this.Id);
                where += DataAccessUtil.GetPartWhereCondition("Name", this.Name);
                where += DataAccessUtil.GetPartWhereCondition("QueryNumber", this.QueryNumber);
                where += DataAccessUtil.GetPartWhereCondition("EnterpriseNumber", this.EnterpriseNumber);
                where += DataAccessUtil.GetPartWhereCondition("Contact", this.Contact);
                where += DataAccessUtil.GetPartWhereCondition("Telephone1", this.Telephone1, true);
                where += DataAccessUtil.GetPartWhereCondition("Telephone2", this.Telephone2, true);
                where += DataAccessUtil.GetPartWhereCondition("WebSite", this.WebSite);
                where += DataAccessUtil.GetPartWhereCondition("Email", this.Email);
                where += DataAccessUtil.GetPartWhereCondition("Postcode", this.Postcode, true);
                where += DataAccessUtil.GetPartWhereCondition("Address", this.Address);

                where += DataAccessUtil.GetPartWhereCondition("CategoryId", this.CategoryId);

                where += DataAccessUtil.GetPartWhereCondition("Scale", this.Scale);
                where += DataAccessUtil.GetPartWhereCondition("EmployeeCount", this.EmployeeCount);

                //where += DataAccessUtil.GetPartWhereCondition("IsDeleted", this.IsDeleted);
                //where += DataAccessUtil.GetPartWhereCondition("IsActive", this.IsActive);
                //where += DataAccessUtil.GetPartWhereCondition("CreatedTime", this.CreatedTime);
                //where += DataAccessUtil.GetPartWhereCondition("CreatedBy", this.CreatedBy);
                //where += DataAccessUtil.GetPartWhereCondition("ModifiedTime", this.ModifiedTime);
                //where += DataAccessUtil.GetPartWhereCondition("LastModifiedBy", this.LastModifiedBy);
                //where += DataAccessUtil.GetPartWhereCondition("Version", this.Version);
                //where += DataAccessUtil.GetPartWhereCondition("Description", this.Description);

                return where;
            }

            public string FilterExpression
            {
                get
                {
                    string where = "";
                    //where += DataAccessUtil.GetPartWhereCondition("Id", this.Id);
                    where += DataAccessUtil.GetPartWhereCondition("Name", this);
                    where += DataAccessUtil.GetPartWhereCondition("QueryNumber", this);
                    where += DataAccessUtil.GetPartWhereCondition("EnterpriseNumber", this);
                    where += DataAccessUtil.GetPartWhereCondition("Contact", this);
                    where += DataAccessUtil.GetPartWhereCondition("Telephone1", this, true);
                    where += DataAccessUtil.GetPartWhereCondition("Telephone2", this, true);
                    where += DataAccessUtil.GetPartWhereCondition("WebSite", this);
                    where += DataAccessUtil.GetPartWhereCondition("Email", this, true);
                    where += DataAccessUtil.GetPartWhereCondition("Postcode", this, true);
                    where += DataAccessUtil.GetPartWhereCondition("Address", this);

                    where += DataAccessUtil.GetPartWhereCondition("CategoryId", this, DbType.Guid);

                    where += DataAccessUtil.GetPartWhereCondition("Scale", this, DbType.Decimal);
                    where += DataAccessUtil.GetPartWhereCondition("EmployeeCount", this, DbType.Int32);
                    where += DataAccessUtil.GetPartWhereCondition("CategoryId", "Categories", this, DbType.String, Husb.Util.ExpressionKind.Contains);

                    //string where = "";
                    //if (this["Id"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("Id", this.Id);
                    //if (this["Name"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("Name", this.Name);
                    //if (this["QueryNumber"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("QueryNumber", this.QueryNumber);
                    //if (this["EnterpriseNumber"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("EnterpriseNumber", this.EnterpriseNumber);
                    //if (this["Contact"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("Contact", this.Contact);
                    //if (this["Telephone1"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("Telephone1", this.Telephone1, true);
                    //if (this["Telephone2"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("Telephone2", this.Telephone2, true);
                    //if (this["WebSite"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("WebSite", this.WebSite);
                    //if (this["Email"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("Email", this.Email);
                    //if (this["Postcode"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("Postcode", this.Postcode, true);
                    //if (this["Address"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("Address", this.Address);

                    //if (this["CategoryId"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("CategoryId", this.CategoryId);

                    //if (this["Scale"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("Scale", this.Scale);
                    //if (this["EmployeeCount"] != System.DBNull.Value) where += DataAccessUtil.GetPartWhereCondition("EmployeeCount", this.EmployeeCount);

                    //where += DataAccessUtil.GetPartWhereCondition("IsDeleted", this.IsDeleted);
                    //where += DataAccessUtil.GetPartWhereCondition("IsActive", this.IsActive);
                    //where += DataAccessUtil.GetPartWhereCondition("CreatedTime", this.CreatedTime);
                    //where += DataAccessUtil.GetPartWhereCondition("CreatedBy", this.CreatedBy);
                    //where += DataAccessUtil.GetPartWhereCondition("ModifiedTime", this.ModifiedTime);
                    //where += DataAccessUtil.GetPartWhereCondition("LastModifiedBy", this.LastModifiedBy);
                    //where += DataAccessUtil.GetPartWhereCondition("Version", this.Version);
                    //where += DataAccessUtil.GetPartWhereCondition("Description", this.Description);

                    return where;
                }
            }

            #endregion
        }
    }
}
